﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace FilStartUps_Mobile.Helpers
{
    public class Helper
    {
        public static string Create()
        {
            string key = string.Empty;
            key = Guid.NewGuid().ToString().Substring(0, 20);
            return key;
        }
        public static string HashPassword(string password)
        {

            SHA1 hash = SHA1.Create();
            ASCIIEncoding encoder = new ASCIIEncoding();
            byte[] combined = encoder.GetBytes(password);
            hash.ComputeHash(combined);
            return Convert.ToBase64String(hash.Hash);

        }
        // Calculate Age
        public static int CalculateAge(DateTime birthDate)
        {
            DateTime now = DateTime.Today;
            int years = now.Year - birthDate.Year;

            if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))
                --years;

            return years;
        }
    }
}